//
//  NetRequestClass.m
//  Village
//
//  Created by 程虎 on 2017/9/15.
//  Copyright © 2017年 程虎. All rights reserved.
//

#import "NetRequestClass.h"

@implementation NetRequestClass

+ (void)GET:(NSString *)URLString Parameters:(NSMutableDictionary *)parameters success:(RequestSuccess)success failure:(RequestFailure)failure
{
    [[AFNetWorkService2 getAFNetWorkService2] requestWithServiceIP2:URLString ServiceName:@"" params:parameters httpMethod:@"GET" resultIsDictionary:YES completeBlock:^(id result, ResultType resultType) {
        if (result != nil) {
            if ([result[@"code"] isEqualToString:@"0"]) {
                success(result[@"data"]);
            }
            else {
                failure(result[@"code"],result[@"message"]);
            }
        }
        else {
            failure(nil,@"网络不给力");
        }
    }];
}

+ (void)Post:(NSString *)URLString Parameters:(NSMutableDictionary *)parameters success:(RequestSuccess)success failure:(RequestFailure)failure
{
    LSLog(@"Request parameters ------ %@",parameters);
    [[AFNetWorkService2 getAFNetWorkService2] requestWithServiceIP2:URLString ServiceName:@"" params:parameters httpMethod:@"POST" resultIsDictionary:YES completeBlock:^(id result, ResultType resultType) {
        LSLog(@"result ------ %@",result);
        if (result != nil) {
            if ([result[@"code"] isEqualToString:@"0"]) {
                success(result);
            }
            else {
                failure(result[@"code"],result[@"message"]);
            }
        }
        else {
            failure(nil,@"网络不给力");
        }
    }];
}

@end
